<?php
include("../../class/connect.php");
$id=(int)$_GET['id'];
$classid=(int)$_GET['classid'];
if(empty($id)||empty($classid))
{
    exit();
}
$num=(int)$_GET['num'];
if(empty($num))
{
	$num=10;
}
$pldate="m-d H:i";//时间格式化
$tbcolor=empty($_GET['tbcolor'])?'CCCCCC':$_GET['tbcolor'];
$tdcolor=empty($_GET['tdcolor'])?'FFFFFF':$_GET['tdcolor'];
$tbwidth=empty($_GET['tbwidth'])?'100%':$_GET['tbwidth'];
$tdheight=empty($_GET['tdheight'])?'20':$_GET['tdheight'];
//截取数
$sub=(int)$_GET['sub'];
if($sub>500)
{
	$sub=0;
}
include("../../class/config.php");
include("../../class/db_sql.php");
include("../../class/q_functions.php");

//去掉原引用
function RepYPlQuote($text){
	$preg_str="/<table (.+?)<\/table>/is";
	$text=preg_replace($preg_str,"",$text);
	return $text;
}

$link=db_connect();
$empire=new mysqlquery();
$sql=$empire->query("select username,saytime,saytext from {$dbtbpre}enewspl where id='$id' and classid='$classid' and checked=0 order by plid desc limit ".$num);
$t="<table width='$tbwidth' border=0 cellpadding=2 cellspacing=1 bgcolor='$tbcolor' align='center' style='WORD-BREAK: break-all; WORD-WRAP: break-word'>";
while($r=$empire->fetch($sql))
{
	if(empty($r[username]))
	{
		$r[username]="匿名";
	}
	$saytime=format_datetime($r['saytime'],$pldate);
	$saytext=str_replace("\r\n","",$r[saytext]);
	if($sub)
	{
		$saytext=RepYPlQuote($saytext);//去掉引用
		$saytext=sub($saytext,0,$sub,false);
	}
	$saytext=RepPltextFace($saytext);//替换表情
	$t.="<tr bgcolor='$tdcolor'><td height='$tdheight' width='20%' align=center>$r[username]</td><td width='62%' style='cursor:crosshair'><div>".$saytext."</div></td><td width='18%' align=center>$saytime</td></tr>";
}
$t.="</table>";
$t=addslashes(stripSlashes($t));
db_close();
$empire=null;
echo"document.write(\"".$t."\");";
?>